package com.shop2cn.iapi.sqpayment.testcase;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.shop2cn.iapi.sqpayment.parameter.AcquireOrderBean;
import com.shop2cn.iapi.sqpayment.parameter.ApproveRefundBean;
import com.shop2cn.iapi.sqpayment.parameter.SubmitRefundBean;
import com.shop2cn.iapi.sqpayment.service.ApproveRefundCall;
import com.shop2cn.iapi.sqpayment.service.ExecuteRefundCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P3;
import com.ymttest.business.service.SQPayGateWayCallService;
import com.ymttest.database.model.MPayment;
import com.ymttest.database.model.MRefund;
import com.ymttest.database.sqlwapper.SQPayGateWayWapper;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;

/**
 * 退款申请审核通过接口
 * FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_ApproveRefund {
    private static ApproveRefundBean approverefundBean;
    private static ApproveRefundCall approverefundCall;
    SQPayGateWayWapper pdw;

    @BeforeClass
    public static void setUp() {
        Logger.createResultFile("退款申请审核通过接口");
    }

    @Before
    public void caseUp() {
        approverefundBean = new ApproveRefundBean();
        approverefundCall = new ApproveRefundCall();
        pdw=new SQPayGateWayWapper();
    }

    @AfterClass
    public static void tearDown() {
        Logger.generateResult(approverefundCall.getOpurl());
    }

    @After
    public void caseDown() {
        Logger.end();
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_001() {
        Logger.start(true, "支付宝审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("10");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_002() {
        Logger.start(true, "不输入PaymentIds审核退款失败");
        try {
            // AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("10");
            // SQPayGateWayCallService.acquireOrder(aqb);
            // SQPayGateWayCallService.notifyCall(aqb);
            // SQPayGateWayCallService.submitRefund(aqb);
            // String pid = SQPayGateWayCallService.getPaymentId(aqb);
            approverefundBean.setApproveUser("AutoTest");
            // List<String> PaymentIds=new ArrayList<String>();
            // PaymentIds.add(pid);
            // approverefundBean.setPaymentIds(PaymentIds);
            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("1000", approverefundCall.getString("ErrorCode"), "验证ErrorCode");
            Logger.verifyEquals("refundIds not be empty", approverefundCall.getString("ErrorMessage"), "验证ErrorMessage");
        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_003() {
        Logger.start(true, "不输入ApproveUses审核退款失败");
        try {
        	AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("10");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
//            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);
            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_004() {
        Logger.start(true, "输入不存在RefundNos审核退款失败");
        try {
            String pid = "000000";
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundNos = new ArrayList<String>();
            refundNos.add(pid);
            approverefundBean.setRefundIds(refundNos);
            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            // FIXME code
            Logger.verifyEquals("3103", approverefundCall.getString("ErrorCode"), "验证ErrorCode");
            Logger.verifyIsContains("退款单号不存在|refund request not exist.",
                    approverefundCall.getString("ErrorMessage"), "验证ErrorMessage");
        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_005() {
        Logger.start(true, "PaymentIds传入空列表审核退款失败");
        try {
            // AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("10");
            // SQPayGateWayCallService.acquireOrder(aqb);
            // SQPayGateWayCallService.notifyCall(aqb);
            // SQPayGateWayCallService.submitRefund(aqb);
            // String pid = SQPayGateWayCallService.getPaymentId(aqb);
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundNos = new ArrayList<String>();
            // PaymentIds.add(pid);
            approverefundBean.setRefundIds(refundNos);
            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("1000", approverefundCall.getString("ErrorCode"), "验证ErrorCode");
            Logger.verifyEquals("refundIds not be empty", approverefundCall.getString("ErrorMessage"), "验证ErrorMessage");
        } catch (Exception e) {
            Logger.fail(e);
        }
    }

    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_006() {
        Logger.start(true, "审核多笔退款成功");
        try {
        	 AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("10");
             SQPayGateWayCallService.acquireOrder(aqb);
             SQPayGateWayCallService.notifyCall(aqb);
             SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
             MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
             String RefundId1 = m.getRefundId().toString();
            
             AcquireOrderBean aqb2 = SQPayGateWayCallService.initAcquireOrder("10");
             SQPayGateWayCallService.acquireOrder(aqb2);
             SQPayGateWayCallService.notifyCall(aqb2);
             SubmitRefundBean submitrefundBean2 = SQPayGateWayCallService.JSubmitRefund(aqb2);
             MRefund m2=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean2.getTraceId()).get(0);
             String RefundId2 = m2.getRefundId().toString();
             
             approverefundBean.setApproveUser("AutoTest");
             List<String> refundIds = new ArrayList<String>();
             refundIds.add(RefundId1);
             refundIds.add(RefundId2);
             approverefundBean.setRefundIds(refundIds);
             
             approverefundBean.setApproveUser("AutoTest");
             
            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("0", approverefundCall.getString("ErrorCode"), "验证ErrorCode");
            Logger.verifyEquals("null", approverefundCall.getString("ErrorMessage"), "验证ErrorMessage");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    @Ignore
    //sq去掉微信退款case
    public void Tc_ApproveRefund_007() {
        Logger.start(true, "微信审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("14");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    @Ignore
    //招商渠道废弃
    public void Tc_ApproveRefund_008() {
        Logger.start(true, "招商审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("50");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_009() {
        Logger.start(true, "applepay审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("60");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_010() {
        Logger.start(true, "宝付审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("70");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_011() {
        Logger.start(true, "花呗审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("9");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    @Ignore
    //sq去掉微信退款case
    public void Tc_ApproveRefund_012() {
        Logger.start(true, "18直播微店审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("18");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    @Ignore
    //sq去掉微信退款case
    public void Tc_ApproveRefund_013() {
        Logger.start(true, "19海外直播扫货微信APP支付审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("18");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_014() {
        Logger.start(true, "80翼支付审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("80");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_015() {
        Logger.start(true, "62upay-app审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("62");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_016() {
        Logger.start(true, "63upay-wap审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("63");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    @Ignore
    //sq去掉微信退款case
    public void Tc_ApproveRefund_017() {
        Logger.start(true, "3017全球优选-商城-微信小程序审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("3017");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_018() {
        Logger.start(true, "64小米支付审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("64");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_019() {
        Logger.start(true, "3013全球优选-支付宝App-微信小程序审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("3013");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    @Ignore
    //sq去掉微信退款case
    public void Tc_ApproveRefund_020() {
        Logger.start(true, "3015全球优选-微信App-微信小程序审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("3015");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_021() {
        Logger.start(true, "65.HuaweiPay审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("65");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_022() {
        Logger.start(true, "66.SamSungPay审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("65");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_023() {
        Logger.start(true, "6000.HipoPayWxApp审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("6000");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.addHeader("Mock", "1");
			String mockid = TestDataManager.getRandomUUID().toString();
			approverefundCall.addHeader("MockId", mockid);
			approverefundCall.addHeader("MockResult-Hipo-is_success", "true");
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_024() {
        Logger.start(true, "花呗8审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("8");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_025() {
        Logger.start(true, "6001.HipoPayWxH5审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("6001");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.addHeader("Mock", "1");
			String mockid = TestDataManager.getRandomUUID().toString();
			approverefundCall.addHeader("MockId", mockid);
			approverefundCall.addHeader("MockResult-Hipo-is_success", "true");
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_026() {
        Logger.start(true, "90分期乐审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("90");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);
            approverefundCall.setData(approverefundBean);
//            MockResult-FqlPay-result: 0
            Map rm = new HashMap();
            rm.put("Mock", "1");
			String mockid = TestDataManager.getRandomUUID().toString();
			rm.put("MockId", mockid);
			rm.put("MockResult-FqlPay-result", "0");
            SQPayGateWayCallService.addMock(approverefundCall, rm);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_027() {
        Logger.start(true, "3113全球优选-支付宝App-微信小程序审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("3113");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    @Ignore
    //sq去掉微信退款case
    public void Tc_ApproveRefund_028() {
        Logger.start(true, "3115全球优选-微信App-微信小程序审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("3115");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    @Ignore
    //sq去掉微信退款case
    public void Tc_ApproveRefund_029() {
        Logger.start(true, "3117全球优选-商城-微信小程序审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("3117");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    @Ignore
    //sq去掉微信退款case
    public void Tc_ApproveRefund_030() {
        Logger.start(true, "3213鱼多多全球优选-支付宝App-微信小程序审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("3213");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    @Ignore
    //sq去掉微信退款case
    public void Tc_ApproveRefund_031() {
        Logger.start(true, "3215鱼多多全球优选-微信App-微信小程序审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("3215");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_032() {
        Logger.start(true, "2013.抖音支付宝审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("2013");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_033() {
        Logger.start(true, "91分期乐小程序审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("91");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);
            approverefundCall.setData(approverefundBean);
//            MockResult-FqlPay-result: 0
            Map rm = new HashMap();
            rm.put("Mock", "1");
			String mockid = TestDataManager.getRandomUUID().toString();
			rm.put("MockId", mockid);
			rm.put("MockResult-FqlPay-result", "0");
            SQPayGateWayCallService.addMock(approverefundCall, rm);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_034() {
        Logger.start(true, "6002HipoPay-微信H5飛界國際電子商務审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("6002");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.addHeader("Mock", "1");
			String mockid = TestDataManager.getRandomUUID().toString();
			approverefundCall.addHeader("MockId", mockid);
			approverefundCall.addHeader("MockResult-Hipo-is_success", "true");
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_035() {
        Logger.start(true, "6010盛付通微信小程序审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("6010");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.addHeader("Mock", "1");
			String mockid = TestDataManager.getRandomUUID().toString();
			approverefundCall.addHeader("MockId", mockid);
			approverefundCall.addHeader("MockResult-Hipo-is_success", "true");
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_036() {
        Logger.start(true, "6011盛付通微信公众号审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("6011");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            Logger.comment("查询部分退款单号");
			MPayment ppm = SQPayGateWayCallService.getPPayment(aqb);
			MRefund mrr = pdw.selectRefundRequestByPaymentId(ppm.getPaymentId()).get(0);
			//此时refundbn尚未生成
			String refundbn = mrr.getRefundBatchNo()!=null?mrr.getRefundBatchNo().toString():" ";
			String refundid = mrr.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundid);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            Map m=getSFTRefundMock( aqb.getPayPrice(), refundbn);
			addMock(approverefundCall, m);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);
        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_037() {
        Logger.start(true, "6103.HipoPay-微信app审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("6103");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.addHeader("Mock", "1");
			String mockid = TestDataManager.getRandomUUID().toString();
			approverefundCall.addHeader("MockId", mockid);
			approverefundCall.addHeader("MockResult-Hipo-is_success", "true");
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_038() {
        Logger.start(true, "6107.HipoPay-支付宝app审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("6107");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.addHeader("Mock", "1");
			String mockid = TestDataManager.getRandomUUID().toString();
			approverefundCall.addHeader("MockId", mockid);
			approverefundCall.addHeader("MockResult-Hipo-is_success", "true");
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_039() {
        Logger.start(true, "6003HipoPay-微信H5飛界國際审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("6003");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.addHeader("Mock", "1");
			String mockid = TestDataManager.getRandomUUID().toString();
			approverefundCall.addHeader("MockId", mockid);
			approverefundCall.addHeader("MockResult-Hipo-is_success", "true");
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_040() {
        Logger.start(true, "4013百度支付宝审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("4013");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    @Ignore
    //sq去除6000以下微信退款的case
    public void Tc_ApproveRefund_041() {
        Logger.start(true, "4016百度微信审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("4016");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_042() {
        Logger.start(true, "6012盛付通支付宝审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("6010");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.addHeader("Mock", "1");
			String mockid = TestDataManager.getRandomUUID().toString();
			approverefundCall.addHeader("MockId", mockid);
			approverefundCall.addHeader("MockResult-Hipo-is_success", "true");
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    @Test
    @Category({P3.class})
    @TestCase
    public void Tc_ApproveRefund_043() {
        Logger.start(true, "6207头条支付宝审核退款成功");
        try {
            AcquireOrderBean aqb = SQPayGateWayCallService.initAcquireOrder("6207");
            SQPayGateWayCallService.acquireOrder(aqb);
            SQPayGateWayCallService.notifyCall(aqb);
            SubmitRefundBean submitrefundBean = SQPayGateWayCallService.JSubmitRefund(aqb);
            MRefund m=new SQPayGateWayWapper().selectRefundRequestByTraceId(submitrefundBean.getTraceId()).get(0);
            String refundId = m.getRefundId().toString();
            approverefundBean.setApproveUser("AutoTest");
            List<String> refundIds = new ArrayList<String>();
            refundIds.add(refundId);
            approverefundBean.setRefundIds(refundIds);

            approverefundCall.setData(approverefundBean);
            approverefundCall.callService();
            Logger.verifyEquals("true",approverefundCall.getString("IsSuccess"),"验证IsSuccess");
            Logger.verifyEquals("0",approverefundCall.getString("ErrorCode"),"验证ErrorCode");
            verifyDB(approverefundBean);

        } catch (Exception e) {
            Logger.fail(e);
        }
    }
    private Map getSFTRefundMock(String refundamt,String refundbn) {
		Logger.comment("获取盛付通默认的Mock信息");
		Map m = new HashMap<String, String>();
		m.put("Mock", "1");
		String mockid = TestDataManager.getRandomUUID().toString();
		m.put("MockId", mockid);
//		MockResult-ShengPay-merchantOrderNo: merchantOrderNo-01
		m.put("MockResult-ShengPay-merchantOrderNo",SQPayGateWayCallService.SFTMerchantNo);
//		MockResult-ShengPay-orderCreateTime: orderCreateTime-01
		m.put("MockResult-ShengPay-orderCreateTime",YMTDateUtil.getBeforeOrNextDay(0, "yyyyMMddHHmmss"));
//		MockResult-ShengPay-refundAmount: 10.1
		m.put("MockResult-ShengPay-refundAmount", refundamt);
//		MockResult-ShengPay-refundOrderNo: refundOrderNo-01
		m.put("MockResult-ShengPay-refundOrderNo", refundbn);
//		MockResult-ShengPay-refundTransNo: refundTransNo-01
		m.put("MockResult-ShengPay-refundTransNo", TestDataManager.getRandomUUID().toString().replaceAll("-", ""));
//		MockResult-ShengPay-returnCode: 01
		m.put("MockResult-ShengPay-returnCode", "01");
//		MockResult-ShengPay-status: 01
		m.put("MockResult-ShengPay-status", "01");
		
		return m;
	}
    private void addMock(ApproveRefundCall cpcall, Map m) {
		Logger.comment("初始化MockHeader信息:" + m.toString());
		Set sl = m.entrySet();
		for (Object o : sl) {
			String[] ss = o.toString().split("=");
			String value = FormatUtil.urlEncode(ss[1]);
			cpcall.addHeader(ss[0], value);
		}
    }
    private void verifyDB(ApproveRefundBean approverefundBean) throws Exception {
        Logger.comment("验证数据库RefundRequest");
        List<String> refundids = approverefundBean.getRefundIds();
        for (int i = 0; i < refundids.size(); i++) {
        	MRefund m =
        			pdw.selectRefundRequestByRefundId(refundids.get(i)).get(0);
            Logger.verifyEquals(1, m.getApproveStatus(), "验证RefundRequest表中ApproveStatus字段与返回一致");
        }
    }
}
